<?php

namespace App\Http\Middleware;


use App\Models\Link;
use Closure;

class HomeLink
{
    public function handle($request, Closure $next)
    {
        view()->share('links',$this->getLinks());
        return $next($request);
    }


    protected function getLinks(){
        $links = Link::select(['id','title','link','target','status'])
            ->where('status',Link::STATUS_1)
            ->orderBy('sort','desc')
            ->get()->toArray();
        return $links;
    }
}
